package com.example.controller;

import com.example.domain.User;
import com.example.service.ChangePasswordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ChangePasswordController {
    @Autowired
    ChangePasswordService changePasswordService;
    @PutMapping("/change-password")
    public Result changePassword(@RequestBody User user) {
        boolean flag = changePasswordService.changePassword(user);
        if (flag) {
            return Result.success(user);
        } else {
            return Result.failure(400,"修改密码失败，请重试！");
        }
    }
}
